<!doctype html>
<!--[if lt IE 7]>      <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang=""> <![endif]-->
<!--[if IE 7]>         <html class="no-js lt-ie9 lt-ie8" lang=""> <![endif]-->
<!--[if IE 8]>         <html class="no-js lt-ie9" lang=""> <![endif]-->
<!--[if gt IE 8]><!-->
<html class="no-js" lang="">
	<!--<![endif]-->

	<head>
		<meta charset="utf-8">
		<meta http-equiv="X-UA-Compatible" content="IE=edge">
		<title>Ela Admin - HTML5 Admin Template</title>
		<meta name="description" content="Ela Admin - HTML5 Admin Template">
		<meta name="viewport" content="width=device-width, initial-scale=1">

		<link rel="stylesheet" href="assets/css/normalize.css">
		<link rel="stylesheet" href="assets/css/bootstrap.min.css">
		<link rel="stylesheet" href="assets/css/font-awesome.min.css">
		<link rel="stylesheet" href="assets/css/themify-icons.css">
		<link rel="stylesheet" href="assets/css/pe-icon-7-filled.css">
		<link rel="stylesheet" href="assets/css/flag-icon.min.css">
		<link rel="stylesheet" href="assets/css/cs-skin-elastic.css">
		<link rel="stylesheet" href="assets/css/style.css">

		<link href='https://fonts.googleapis.com/css?family=Open+Sans:400,600,700,800' rel='stylesheet' type='text/css'>

		<!-- <script type="text/javascript" src="https://cdn.jsdelivr.net/html5shiv/3.7.3/html5shiv.min.js"></script> -->

	</head>

	<body>
		<!-- Left Panel -->
		<aside id="left-panel" class="left-panel">
			<nav class="navbar navbar-expand-sm navbar-default">
				<div id="main-menu" class="main-menu collapse navbar-collapse">
					<ul class="nav navbar-nav">
						<li class="active">
							<a href="index.html"><i class="menu-icon fa fa-laptop"></i>后台管理 </a>
						</li>
						<li class="menu-item-has-children dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="menu-icon fa fa-cogs"></i>管理员中心</a>
							<ul class="sub-menu children dropdown-menu">
								<li><i class="fa fa-id-card-o"></i>
									<a href="ui-cards.html">个人信息</a>
								</li>
								<li><i class="fa fa-file-word-o"></i>
									<a href="forget.html">修改密码</a>
								</li>
							</ul>
						</li>
						<li>
							<a href="hospital.html"> <i class="menu-icon fa fa-table"></i>医院管理</a>
						</li>
						<li>
							<a href="doctor.html"> <i class="menu-icon fa fa-th"></i>医生管理</a>
						</li>

						<li class="menu-item-has-children dropdown">
							<a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="menu-icon fa fa-tasks"></i>用户管理</a>
							<ul class="sub-menu children dropdown-menu">
								<li><i class="menu-icon fa fa-fort-awesome"></i>
									<a href="font-fontawesome.html">Font Awesome</a>
								</li>
								<li><i class="menu-icon ti-themify-logo"></i>
									<a href="font-themify.html">Themefy Icons</a>
								</li>
							</ul>
						</li>

						<li>
							<a href="disease.html"><i class="menu-icon fa fa-street-view"></i>疾病管理</a>
						</li>
						<!-- /.menu-title -->
						<li class="active">
							<a href="drug.html"> <i class="menu-icon fa fa-glass"></i>药品管理</a>
						</li>

						<li class="menu-item-has-children dropdown">
							<a href="" class="dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"> <i class="menu-icon fa fa-bar-chart"></i>统计排行</a>
							<ul class="sub-menu children dropdown-menu">
								<li><i class="menu-icon fa fa-line-chart"></i>
									<a href="hosrank.html">医院统计</a>
								</li>
								<li><i class="menu-icon fa fa-area-chart"></i>
									<a href="doctorrank.html">医生统计</a>
								</li>
								<li><i class="menu-icon fa fa-pie-chart"></i>
									<a href="charts-peity.html">疾病统计</a>
								</li>
							</ul>
						</li>
					</ul>
				</div>
				<!-- /.navbar-collapse -->
			</nav>
		</aside>
		<!-- /#left-panel -->

		<!-- Right Panel -->

		<div id="right-panel" class="right-panel">

			<!-- Header-->
			<header id="header" class="header">
				<div class="top-left">
					<div class="navbar-header">
						<a class="navbar-brand" href="./"><img src="images/logo.png" alt="Logo"></a>
						<a class="navbar-brand hidden" href="./"><img src="images/logo2.png" alt="Logo"></a>
						<a id="menuToggle" class="menutoggle"><i class="fa fa-bars"></i></a>
					</div>
				</div>
				<div class="top-right">
					<div class="header-menu">
						<div class="header-left">
							<button class="search-trigger"><i class="fa fa-search"></i></button>
							<div class="form-inline">
								<form class="search-form">
									<input class="form-control mr-sm-2" type="text" placeholder="Search ..." aria-label="Search">
									<button class="search-close" type="submit"><i class="fa fa-close"></i></button>
								</form>
							</div>

							<div class="dropdown for-notification">
								<button class="btn btn-secondary dropdown-toggle" type="button" id="notification" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <i class="fa fa-bell"></i>
                                <span class="count bg-danger">3</span>
                            </button>
								<div class="dropdown-menu" aria-labelledby="notification">
									<p class="red">You have 3 Notification</p>
									<a class="dropdown-item media" href="#">
										<i class="fa fa-check"></i>
										<p>Server #1 overloaded.</p>
									</a>
									<a class="dropdown-item media" href="#">
										<i class="fa fa-info"></i>
										<p>Server #2 overloaded.</p>
									</a>
									<a class="dropdown-item media" href="#">
										<i class="fa fa-warning"></i>
										<p>Server #3 overloaded.</p>
									</a>
								</div>
							</div>

							<div class="dropdown for-message">
								<button class="btn btn-secondary dropdown-toggle" type="button" id="message" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                <i class="fa fa-envelope"></i>
                                <span class="count bg-primary">4</span>
                            </button>
								<div class="dropdown-menu" aria-labelledby="message">
									<p class="red">You have 4 Mails</p>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/1.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Jonathan Smith</span>
											<span class="time float-right">Just now</span>
											<p>Hello, this is an example msg</p>
										</div>
									</a>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/2.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Jack Sanders</span>
											<span class="time float-right">5 minutes ago</span>
											<p>Lorem ipsum dolor sit amet, consectetur</p>
										</div>
									</a>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/3.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Cheryl Wheeler</span>
											<span class="time float-right">10 minutes ago</span>
											<p>Hello, this is an example msg</p>
										</div>
									</a>
									<a class="dropdown-item media" href="#">
										<span class="photo media-left"><img alt="avatar" src="images/avatar/4.jpg"></span>
										<div class="message media-body">
											<span class="name float-left">Rachel Santos</span>
											<span class="time float-right">15 minutes ago</span>
											<p>Lorem ipsum dolor sit amet, consectetur</p>
										</div>
									</a>
								</div>
							</div>
						</div>

						<div class="user-area dropdown float-right">
							<a href="#" class="dropdown-toggle active" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
								<img class="user-avatar rounded-circle" src="images/admin.jpg" alt="User Avatar">
							</a>

							<div class="user-menu dropdown-menu">
								<a class="nav-link" href="#"><i class="fa fa-user"></i>My Profile</a>

								<a class="nav-link" href="#"><i class="fa fa-bell-o"></i>Notifications <span class="count">13</span></a>

								<a class="nav-link" href="#"><i class="fa fa-cog"></i>Settings</a>

								<a class="nav-link" href="#"><i class="fa fa-power-off"></i>Logout</a>
							</div>
						</div>
					</div>
				</div>
			</header>
			<!-- /header -->
			<!-- Header-->

			<div class="breadcrumbs">
				<div class="breadcrumbs-inner">
					<div class="row m-0">
						<div class="col-sm-4">
							<div class="page-header float-left">
								<div class="page-title">
									<h1 id="name">药品名字</h1>
								</div>
							</div>
						</div>
						<div class="col-sm-8">
							<div class="page-header float-right">
								<div class="page-title">
									<ol class="breadcrumb text-right">
										<li>
											<a href="#">后台管理</a>
										</li>
										<li>
											<a href="#">药品</a>
										</li>
										<li class="active">详情</li>
									</ol>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>

			<div class="content">
				<div class="row" style="margin-bottom: 20px;">
					<div class="col-lg-12">
						<div class="card">
							<div class="card-header">
								<strong>详细信息</strong>
							</div>
							<div class="card-body card-block">

								<div class="row form-group">
									<div class="col col-md-3"><label for="email-input" class=" form-control-label">治疗疾病</label></div>
									<div class="col-6 col-md-5">
										<select id="select-jb-one" class="form-control">
											<option value="">药品类型</option>
										</select>

									</div>
									<div class="col-6 col-md-4">
										<select id="select-jb-two" class="form-control">
											<!--此处填充二级基疾病-->
										</select>
									</div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="text-input" class=" form-control-label"></label></div>
									<div class="col-12 col-md-9"><input type="text" id="jb" placeholder="疾病" class="form-control"></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="password-input" class=" form-control-label">处方类型</label></div>
									<div class="col-12 col-md-9">
										<select id="select-chufang" class="form-control">
											<option value="OTC非处方药物（甲类）">OTC非处方药物（甲类）</option>
											<option value="OTC非处方药物（乙类）">OTC非处方药物（乙类）</option>
										</select>
									</div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="disabled-input" class=" form-control-label">中西类型</label></div>
									<div class="col-12 col-md-9">
										<select id="select-zhongxi" class="form-control">
											<option value="中成药">中成药</option>
											<option value="西药">西药</option>
										</select>
									</div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="disabled-input" class=" form-control-label">医保类型</label></div>
									<div class="col-12 col-md-9">
										<select id="select-yibao" class="form-control">
											<option value="医保甲类">医保甲类</option>
											<option value="医保乙类">医保乙类</option>
											<option value="限工伤保险">限工伤保险</option>
											<option value="非医保">非医保</option>
										</select>
									</div>
								</div>

								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">主要成分</label></div>
									<div class="col-12 col-md-9"><textarea id="chengfen" rows="5" placeholder="成分" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">主要治疗</label></div>
									<div class="col-12 col-md-9"><textarea id="zhuzhi" rows="5" placeholder="主要治疗" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">使用剂量</label></div>
									<div class="col-12 col-md-9"><textarea id="yongliang" rows="5" placeholder="用量" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">不良反应</label></div>
									<div class="col-12 col-md-9"><textarea id="buliang" rows="5" placeholder="不良反应" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">使用禁忌</label></div>
									<div class="col-12 col-md-9"><textarea id="jingji" rows="5" placeholder="禁忌" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">注意事项</label></div>
									<div class="col-12 col-md-9"><textarea id="zhuyi" rows="5" placeholder="注意事项" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">相互作用</label></div>
									<div class="col-12 col-md-9"><textarea id="xianghu" rows="5" placeholder="相互作用" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">储藏方法</label></div>
									<div class="col-12 col-md-9"><textarea id="chucang" rows="5" placeholder="储藏方法" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">有效期</label></div>
									<div class="col-12 col-md-9"><textarea id="youxiaoqi" rows="5" placeholder="有效期" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">批文</label></div>
									<div class="col-12 col-md-9"><textarea id="piwen" rows="5" placeholder="批文" class="form-control"></textarea></div>
								</div>
								<div class="row form-group">
									<div class="col col-md-3"><label for="textarea-input" class=" form-control-label">生成公司</label></div>
									<div class="col-12 col-md-9"><textarea id="gongsi" rows="5" placeholder="公司" class="form-control"></textarea></div>
								</div>
							</div>
							<div class="card-footer">
								<button type="submit" class="btn btn-primary btn-sm">
                                    <i class="fa fa-dot-circle-o"></i> Submit
                                </button>
								<button type="reset" class="btn btn-danger btn-sm">
                                    <i class="fa fa-ban"></i> Reset
                                </button>
							</div>
						</div>

					</div>

				</div>
				<div class="animated fadeIn">
					<div class="row">
						<div class="col-lg-12">
							<div class="card">
								<div class="table-stats order-table ov-h">

								</div>
								<!-- /.table-stats -->
							</div>
						</div>
						<div class="col-lg-8">
							<button class="btn btn-outline-info" type="submit" id="btn-save">保存</button>
							<button class="btn btn-outline-info" type="submit" id="btn-back" onclick="toback()">返回</button>
						</div>
						<div class="col-lg-4">

						</div>
					</div>
				</div>
				<!-- .animated -->
			</div>
			<!-- .content -->

			<div class="clearfix"></div>

			<footer class="site-footer">
				<div class="footer-inner bg-white">
					<div class="row">
						<div class="col-sm-6">
							Copyright &copy; 2018 XX Admin. More Templates
							<a href="http://www.cssmoban.com/" target="_blank" title="XX">XX</a> - Collect from
							<a href="http://www.cssmoban.com/" title="XX" target="_blank">XX</a>
						</div>
						<div class="col-sm-6 text-right"> Designed by Colorlib
						</div>
					</div>
				</div>
			</footer>

		</div>
		<!-- /#right-panel -->

		<!-- Right Panel -->

		<!-- Scripts -->
		<script src="assets/js/vendor/jquery-2.1.4.min.js"></script>
		<script src="assets/js/popper.min.js"></script>
		<script src="assets/js/bootstrap.min.js"></script>
		<script src="assets/js/jquery.matchHeight.min.js"></script>
		<script src="assets/js/main.js"></script>

		<script>
			var $ = jQuery.noConflict();
			//获取url参数
			function urlParam() {
				var str = location.href; //取得整个地址栏
				var param = str.split("=");
				console.log(decodeURI(param[1]));
				return decodeURI(param[1]);
			}
			//获取药品列表
			getDrug(urlParam());

			//获取所有一级疾病
			getJBAllOne();

			function getDrug(id) {
				jQuery.ajax({
					url: "http://127.0.0.1:8000/drug/getByIf",
					data: {
						pageNum: 1,
						pageSize: 1,
						id: id,
					},
					type: 'POST',
					dataType: "json",
					success: function(d) {
						$("#name").html(d[0].name)
						$("#chengfen").val(d[0].chengfen)
						$("#zhuzhi").val(d[0].zhuzhi)
						$("#yongliang").val(d[0].yongliang)
						$("#buliang").val(d[0].buliang)
						$("#jingji").val(d[0].jingji)
						$("#zhuyi").val(d[0].zhuyi)
						$("#xianghu").val(d[0].xianghu)
						$("#chucang").val(d[0].chucang)
						$("#youxiaoqi").val(d[0].youxiaoqi)
						$("#piwen").val(d[0].piwen)
						$("#gongsi").val(d[0].gongsi)
						$("#jb").val(d[0].jb)
						$("#select-chufang").val(d[0].chufang)
						$("#select-zhongxi").val(d[0].zhongxi)
						$("#select-yibao").val(d[0].yibao)
					}
				});
			}

			//二级疾病
			function getJBByOne(one) {
				jQuery.ajax({
					url: "http://127.0.0.1:8000/drug/getDrugTwoByOne",
					data: {
						one: one
					},
					type: 'POST',
					dataType: "json",
					success: function(d) {
						for(i = 0; i < d.length; i++) {
							addElOption("select-jb-two", d[i]);
						}
					}
				});
			}

			//一级疾病
			function getJBAllOne() {
				jQuery.ajax({
					url: "http://127.0.0.1:8000/drug/allDrugOne",
					type: 'GET',
					dataType: "json",
					success: function(d) {
						for(i = 0; i < d.length; i++) {
							addElOption("select-jb-one", d[i]);
							//console.log(d[i]);
						}
					}
				});
			}

			function addElOption(container, obj) {
				var el = '<option value="' + obj + '">' + obj + '</option>';
				$("#" + container).append(el);
			}

			//选择一级疾病
			$("#select-jb-one").change(function() {
				$("#select-jb-two").empty();
				var one = $("#select-jb-one").val();
				getJBByOne(one);
				$("#select-jb-two").focus();
			});

			//选择二级疾病
			$("#select-jb-two").change(function() {
				$("#jb").val($("#select-jb-two").val());
			});

			$("#btn-save").click(function() {
				var chengfen = $("#chengfen").val()
				var zhuzhi = $("#zhuzhi").val()
				var yongliang = $("#yongliang").val()
				var buliang = $("#buliang").val()
				var jingji = $("#jingji").val()
				var zhuyi = $("#zhuyi").val()
				var xianghu = $("#xianghu").val()
				var chucang = $("#chucang").val()
				var youxiaoqi = $("#youxiaoqi").val()
				var piwen = $("#piwen").val()
				var gongsi = $("#gongsi").val()
				var jb = $("#jb").val()
				var chufang = $("#select-chufang").val()
				var zhongxi = $("#select-zhongxi").val()
				var yibao = $("#select-yibao").val()

				jQuery.ajax({
					url: "http://127.0.0.1:8000/drug/update",
					data: {
						id: urlParam(),
						chengfen: chengfen,
						zhuzhi: zhuzhi,
						yongliang: yongliang,
						buliang: buliang,
						jingji: jingji,
						zhuyi: zhuyi,
						xianghu: xianghu,
						chucang: chucang,
						youxiaoqi: youxiaoqi,
						piwen: piwen,
						gongsi: gongsi,
						jb: jb,
						chufang: chufang,
						zhongxi: zhongxi,
						yibao: yibao,
					},
					type: 'POST',
					dataType: "json",
					//async: false,
					success: function(d) {
						if(d > 0) {
							alert("保存成功");
						}
					}
				});
			})

			function toback() {
				window.location.href = "drug.html";
			}
		</script>
	</body>

</html>